<!DOCTYPE html>
<html><head>
        <meta charset="utf-8">
    <title>学无止境，耐得住寂寞的人最坚强！</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__ADMIN__/style/bootstrap.css" rel="stylesheet">
    <link href="__ADMIN__/style/font-awesome.css" rel="stylesheet">
    <link href="__ADMIN__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__ADMIN__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__ADMIN__/style/demo.css" rel="stylesheet">
    <link href="__ADMIN__/style/typicons.css" rel="stylesheet">
    <link href="__ADMIN__/style/animate.css" rel="stylesheet">
    <style type="text/css">
        .open{
            border: 1px solid #ccc;
            padding: 0 4px;
            cursor: pointer;
        }
    </style>
</head>
<body>

    {include file="public/header"}
    <!-- /头部 -->
   
    <div class="main-container container-fluid">
        <div class="page-container">
                        <!-- Page Sidebar -->
            {include file="public/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="{:url('admin/index/index')}">系统</a>
                    </li>
                                        <li class="active">用户管理</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<button type="button" tooltip="添加用户" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{:url('cate/add')}'"> <i class="fa fa-plus"></i> Add
</button>
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-body">
                <div class="flip-scroll">
                 <form action="{:url('cate/delete')} " method="post" >
                    <table class="table table-bordered table-hover">
                        <thead class="">
                            <tr pid="0">
                                <th width="5%" class="text-center" >伸缩</th>
                                <th class="text-center" width="6%">
                                    <label>
                                        <input id="checkall" class="colored-bule" type="checkbox">
                                        <span class="text"></span>
                                    </label>
                                </th>

                                <th width="5%" class="text-center" >排序</th>
                                <th width="6%" class="text-center">ID</th>
                                <th >栏目名称</th>
                                <th  width="10%" class="text-center">状态</th>
                                <th  width="10%" class="text-center">属性</th>
                                <th width="10%" class="text-center">所属模型</th>
                                <th  width="20%" class="text-center">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {volist name="cateres" id="cate"}
                        <tr id="{$cate.id}" pid="{$cate.pid}">
                            <td  align="center"><span class="open">＋</span></td>
                                <td align="center">
                                    <label>
                                        <input name="itm[]" value="{$cate.id}"  class="colored-bule" type="checkbox">
                                        <span class="text"></span>
                                    </label>
                                </td>

                            <td align="center"  >
                            <input style="width:35px; text-align:center;" type="text" cateid="{$cate.id}" onchange="changeOrder(this)" name="{$cate.id}" value="{$cate.sort}">
                            </td>

                                <td align="center">{$cate.id}</td>
                                <td >
                                <?php if($cate['level'] !== 0){ echo '├';}?>
                                    <?php echo str_repeat('--',$cate['level']*2)?><a href="{:url('document/lst',['cateid'=>$cate.id,'model_id'=>$cate.model_id])}">{$cate.cate_name}</a>
                                    <a class="btn btn-sm btn-azure btn-addon" style="float: right;" href="{:url('cate/add',array('cateid'=>$cate['id']))}"><i class="fa fa-plus"></i>添加子栏目</a>
                                </td>
                                <td align="center">
                                <a cateid="{$cate.id}" onclick="changestatus(this);" href="javascript:;" {if condition="$cate.status eq 1"} class="btn btn-primary btn-sm shiny"  {else /} class="btn btn-danger btn-sm shiny" {/if} >
                                {if condition="$cate.status eq 1"}  显示 {else /} 隐藏{/if} 
                                </a> </td>
                               
                                <td align="center">
                                {if condition="$cate.cate_attr eq 1"}  列表栏目 {else /} 频道封面{/if}
                                </td>
                                <td align="center">
                                   {$cate.model_name}
                                </td>
                                <td align="center">

                                    <a href="{:url('cate/edit',array('cateid'=>$cate['id']))}" class="btn btn-primary btn-sm shiny">
                                        <i class="fa fa-edit"></i> 编辑
                                    </a>
                                    <a href="#" onClick="warning('确实要删除吗', '{:url('cate/del',array('cateid'=>$cate['id']))}')" class="btn btn-danger btn-sm shiny">
                                        <i class="fa fa-trash-o"></i> 删除
                                    </a>
                                </td>
                        </tr>
                        {/volist}                                
                                         
                        </tbody>
                    </table>
                    <div>
                    <input class="btn btn-primary btn-sm shiny" style="margin-top:10px" type="submit" value="批量删除"></div>
            </form>
                </div>
                <div>
                	                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <script src="__ADMIN__/style/bootstrap.js"></script>
    <script src="__ADMIN__/style/jquery.js"></script>
    <script src="__ADMIN__/org/layer/layer.js"></script>
    <!--Beyond Scripts-->
    <script src="__ADMIN__/style/beyond.js"></script>
    <script type="text/javascript"> 
    //无限极分类子栏目伸缩js
    $('tr[pid!=0]').hide();
    $('.open').click(function(){
        var id=$(this).parents('tr').attr('id');
        if($(this).text() == '＋'){
            $(this).text('－');
            $('tr[pid='+id+']').show();
        }else{
            $(this).text('＋');
            //$('tr[pid='+id+']').hide();
            $.ajax({
            type:"post",
            dataType:"json",
            data:{cateid:id},
            url:"{:url('cate/ajaxlst')}",
            success:function(data){
                //alert(typeof(data));
                //遍历json数组
                var sonids=[];
                var ids= $('tr[pid!=0]');
                ids.each(function(k,v){
                    sonids.push($(this).attr('id'));
                });

                $.each(data,function(k,v){
                    if($.inArray(v,sonids)){
                        $('tr[id='+v+']').hide();
                         $('tr[id='+v+']').find('span:first').text('＋');
                    }
                });
            }
        });
        }
    });

    //分类排序ajax修改
    function changeOrder(obj){
        var cateid=$(obj).attr("cateid");
        var cate_order=$(obj).val();
        $.ajax({
            type:"post",
            dataType:"json",
            data:{cateid:cateid,cate_order:cate_order},
            url:"{:url('cate/changeOrder')}",
            success:function(data){
                if(data.status == 0){
                    layer.msg(data.msg, {icon: 6});
                }else{
                    layer.msg(data.msg, {icon: 5});
                }
            }
        });
       
    }


    //修改状态栏
    function changestatus(obj){
        var cateid=$(obj).attr("cateid");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{cateid:cateid},
            url:"{:url('cate/changestatus')}",
            success:function(data){
                if(data ==1){
                    $(obj).attr('class',"btn btn-danger btn-sm shiny");
                    $(obj).text('隐藏');//有显示改为隐藏
                }else{
                    $(obj).attr('class',"btn btn-primary btn-sm shiny");
                    $(obj).text('显示');//有隐藏改为显示
                }
            }
        });
    }

    //全选处理
    $("#checkall").click(function(){
        if($("#checkall").attr('checked')){
            $(".colored-bule").removeAttr('checked');
           window.location.href="{:url('cate/lst')}";
        }else{
            $(".colored-bule").attr('checked','checked');
        }
    });
    


    </script>


</body></html>